<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增会员等级')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-memberLv-add">
			<div class="form-group">	
				<label class="col-sm-3 control-label">等级名称：</label>
				<div class="col-sm-8">
					<input id="name" name="name" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">等级LOGO：</label>
				<div class="col-sm-8">
					<input id="logo" name="logo" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">会员折扣率：</label>
				<div class="col-sm-8">
					<input id="disCount" name="disCount" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">前一级别：</label>
				<div class="col-sm-8">
					<select id="preId" name="preId" class="form-control">
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">是否默认：</label>
				<div class="col-sm-8">
					<select name="defaultLv" class="form-control">
						<option value="0">否</option>
						<option value="1">是</option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">升级所需积分：</label>
				<div class="col-sm-8">
					<input id="point" name="point" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<input id="remark" name="remark" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">过期时间：</label>
				<div class="col-sm-8">
					<input id="expireTime" name="expireTime" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">过期时间单位</label>
				<div class="col-sm-8">
					<select id="expireTimeUnit" name="expireTimeUnit" class="form-control">
						<option value="1">小时</option>
						<option value="2">天</option>
						<option value="3">月</option>
						<option value="4">年</option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">状态</label>
				<div class="col-sm-8">
					<select id="disabled" name="disabled" class="form-control">
						<option value="0">有效</option>
						<option value="1">无效</option>
					</select>
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "member/memberLv"

		$(function() {
			$('#preId').empty('');
			$('#preId').append('<option value="" selected="selected">无</option>');
			$.ajax({
				url: ctx + "member/memberLv/list",
				type: 'POST',
				data: {
					disabled: 0
				},
				success: function (result) {
					if(result.code == web_status.SUCCESS) {
						if(result.total > 0) {
							var rows = result.rows;
							rows.forEach(function(item, index) {
								$('#preId').append('<option value="'+ item.memberLvId +'">'+item.name+'</option>');
							});
						}
					} else {

					}
				}
			});
		});

		$("#form-memberLv-add").validate({
			rules:{
				name:{
					required:true,
					maxlength: 100
				},
				disCount:{
					required:true,
					number:true,
					max:1,
					min:0
				},
				defaultLv:{
					required:true
				},
				point:{
					required:true,
					digits:true,
					min:0
				},
				expireTime:{
					required:true
				},
				expireTimeUnit:{
					required:true
				},
				disabled:{
					required:true
				}
			},
			focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/add", $('#form-memberLv-add').serialize());
	        }
	    }
	</script>
</body>
</html>
